﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DungeonMaker
{
    class MakeSquare : CellCreator
    {
        public Position sPos = new Position();
        public MakeSquare():base() { }

#region MakeSquare

        public void MakeBase(int width, int height)
        {
            MakeCenter(width, height);
            MakeTop(width);
            MakeBottom(width, height);
            foreach (var e in walls)
            {
                g.WriteCharAt(e.symbol, e.pos);
            }
        }
        private List<Entity> MakeTop(int width)
        {
            var temp = new List<Entity>();
            int x = 0;
            var c = g.GetCharcode(0);
            for (int i = 0; i < width; i++)
            {
                //201,205,187
                if (x == 0)
                {
                    c = g.GetCharcode(201);
                }
                else if (x == width - 1)
                {
                    c = g.GetCharcode(187);
                }
                else
                    c = g.GetCharcode(205);

                x++;
                temp.Add(new Entity(c, new Position(x + sPos.X)));
            }
            return temp;
        }
        private List<Entity> MakeCenter(int width, int height)
        {
            var temp = new List<Entity>();
            int x = 0;
            int y = 1;
            char c;
            for (int i = 0; i < width * height; i++)
            {

                if (x == width)
                {
                    x = 0;
                    y++;

                }
                if (x == 0 || x == width - 1)
                {
                    c = g.GetCharcode(186);
                    temp.Add(new Entity(c, new Position(x+sPos.X, y+sPos.Y)));

                }

                x++;


            }
            return temp;
        }
        private List<Entity> MakeBottom(int width, int y)
        {
            var temp = new List<Entity>();
            int x = 0;
            char c;
            for (int i = 0; i < width; i++)
            {
                if (x == 0)
                {
                    c = g.GetCharcode(200);
                }
                else if (x == width - 1)
                {
                    c = g.GetCharcode(188);
                }
                else
                {
                    c = g.GetCharcode(205);
                }
                x++;
                temp.Add(new Entity(c, new Position(x+sPos.X, y+sPos.Y)));
            }
            return temp;
        }

#endregion
    }
}
